﻿

@model PagedList<View_OrderPlace>
@{
    ViewBag.Title = "预定订单列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    OrderPlaceQueryModel paramModel = new OrderPlaceQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (OrderPlaceQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();

}
<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("OrderPlaceList", "OrderPlace")" method="get">
    <div class="form_query">
        <div>
            商品id：
            <input type="text" name="goods_id" id="goods_id" class="abc input-default" placeholder="" value="@paramModel.goods_id">&nbsp;
        </div>
        <div>
            料号：
            <input type="text" name="MPN" id="MPN" class="abc input-default" placeholder="" value="@paramModel.MPN">&nbsp;
        </div>
        <div>
            会员手机号：
            <input type="text" name="account_mobile" id="account_mobile" class="abc input-default" placeholder="" value="@paramModel.account_mobile">&nbsp;
        </div>
        <div>
            报价状态：
            <select id="place_status" name="place_status">
                <option value="-10" @(paramModel.place_status == -10 ? "selected" : "")>全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    MyEnumHelper.GetEnumItems(typeof(PlaceStatus)).ForEach(t =>
                    {
                        dc.Add(t.Value.ToString(), t.Description);
                    });
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.place_status.ToString());
            </select>&nbsp;
        </div>
        <div>
            是否有效报价：
            <select id="is_del" name="is_del">
                <option value="-10" @(paramModel.is_del == -10 ? "selected" : "")>全部报价</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add("0", "有效报价");
                    dc.Add("1", "失效报价");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.is_del.ToString());
            </select>&nbsp;
        </div>
        <div>
            报价时间：
            <input type="text" name="update_time_begin" class="calendar calendar-time" id="update_time_begin" value="@paramModel.update_time_begin.ToString(1)"> - <input type="text" name="update_time_end" class="calendar calendar-time" id="update_time_end" value="@paramModel.update_time_end.ToString(1)">&nbsp;

        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>商品id</th>
            <th>料号</th>
            <th>会员手机号</th>
            <th>报价时间</th>
            <th>报价金额</th>
            <th>报价状态</th>
            <th>是否中标</th>
            <th>是否有效报价</th>
            <th>预热结束时间</th>
            <th>销售订单号</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td>@m.goods_id</td>
                <td><a href="@Url.Action("detailInfo", "product", new { id = m.goods_id })">@m.MPN</a></td>
                <td><a href="@Url.Action("defailinfo", "account",new { uid = m.uid })">@m.account_mobile </a></td>
                <td>@m.update_time.ToString(1)</td>
                <td>@m.place_price</td>
                <td>
                    @{
                        switch (m.place_status)
                        {
                            case (int)PlaceStatus.Placeing:
                                @:<div>@(MyEnumHelper.GetEnumItemDescription<PlaceStatus>(m.place_status))</div>
                                break;
                            case (int)PlaceStatus.WaitPay:
                                @:<div class="blue">@(MyEnumHelper.GetEnumItemDescription<PlaceStatus>(m.place_status))</div>
                                break;
                            case (int)PlaceStatus.Complete:
                                @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<PlaceStatus>(m.place_status))</div>
                                break;
                            case (int)PlaceStatus.Cancel:
                                @:<div class="gray">@(MyEnumHelper.GetEnumItemDescription<PlaceStatus>(m.place_status))</div>
                                break;
                        }
                    }
                </td>
                <td>
                    @{
                        switch (m.is_hit)
                        {
                            case 1:
                                @:<div class="green">中标</div>
                                break;
                            default:
                                @:<label class="gray">未中标</label>
                                @*if (m.is_del == 0 && m.place_status == (int)PlaceStatus.Placeing)
                                {
                                    <a href="@Url.Action("setHit", "OrderPlace", new { id = m.seq_id })"> 设为中标</a>
                                }*@
                                break;
                        }
                    }
                </td>
                <td>
                    @{
                        switch (m.is_del.Value)
                        {
                            case 0:
                                @:<div class="green">有效报价</div>
                                break;
                            case 1:
                            default:
                                @:<div class="gray">失效报价</div>
                                break;
                        }
                    }
                </td>
                <td>
                    @m.end_time.ToString(1)
                    @if (m.end_time < DateTime.Now)
                    {
                        <info class="gray">已结束</info>
                    }
                    else
                    {
                        <info class="red">剩余：@DateTimeHelper.DateDiffStr(DateInterval.Minute, DateTime.Now, m.end_time)</info>
                    }
                </td>
                <td><a href="@Url.Action("OrderMasterInfo","OrderMaster",new {id=m.order_master_id})">@m.order_NO</a></td>
                <td>
                    <a href="@Url.Action("OrderPlaceInfo", "OrderPlace", new { id = m.seq_id})">查看详情</a>

                </td>
            </tr>
        }
        <tr>
            <td colspan="20"></td>
        </tr>
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    var cancelButton =
        {
            text: '取消',
            elCls: 'button',
            handler: function () {
                this.close();
            }
        };
    reloadHandler = function ()
    {
        window.location.reload();
    }
    function setHit(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要将该报价设为中标吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("setHit", "OrderMaster")";
                      parameter = {
                          id: id
                      };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
                },
                cancelButton
            ]
        });
    }

    function setHitMore(withdraw) {
        var ids = getCheckboxList();
        if (ids.length == 0) {
            BUI.Message.Alert("请选择要设为中标的数据", 'warning');
            return;
        }

        BUI.Message.Show({
            title: '提示',
            msg: '确定要将选择的物料都设为中标吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("setHitMore", "OrderMaster")";
                      parameter = {
                        withdraw: withdraw,
                        ids: ids
                      };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
              },
                cancelButton

            ]
        });
    }

</script>